package com.snpic.appaw.module.third.controller.app.aliyun;

import com.aliyun.dypnsapi20170525.models.GetAuthTokenResponseBody;
import com.snpic.appaw.framework.common.pojo.CommonResult;
import com.snpic.appaw.module.third.api.aliyun.PhoneNumberAuthenticationApi;
import com.snpic.appaw.module.third.api.aliyun.dto.GetAuthTokenRequestDTO;
import com.snpic.appaw.module.third.service.aliyun.PhoneNumberAuthenticationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static com.snpic.appaw.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.snpic.appaw.module.third.enums.ErrorCodeConstants.ALIYUN_INTERFACE01_ERROR;

/**
 * @author JiJun
 * @date 2025/9/21 15:48
 * @修改时间 2025/9/21 15:48
 * @description 阿里云号码认证API实现类
 */
@Tag(name = "C端 - 第三方接口Controller - 阿里云号码认证")
@RestController
@RequestMapping("/third/aliyun")
@Validated
public class PhoneNumberAuthenticationController{

	@Resource
	private PhoneNumberAuthenticationService phoneNumberAuthenticationService;

	@PostMapping("/getAuthToken")
	@Operation(summary = "获取H5认证授权Token")
	public CommonResult<GetAuthTokenResponseBody> getAuthToken(@RequestBody @Valid GetAuthTokenRequestDTO reqDTO) {
		GetAuthTokenResponseBody authToken = null;
		try {
			authToken = phoneNumberAuthenticationService.getAuthToken(reqDTO);
		} catch (Exception e) {
			throw exception(ALIYUN_INTERFACE01_ERROR);
		}
		return CommonResult.success(authToken);
	}

		@GetMapping("/getPhoneWithToken")
	@Operation(summary = "一键登录取号（H5能力专用）")
	public CommonResult<GetAuthTokenResponseBody> getPhoneWithToken(@RequestParam(required = true) @NotEmpty(message = "spToekn必传") String SpToken) {
		GetAuthTokenResponseBody authToken = null;
		//未完成.
		return CommonResult.success(authToken);
	}
}
